﻿@model Huirui.Cavan.Presentation.ViewModel.StockModule.IWareHouseViewModel
@{
    ViewBag.Title = "addWareHouse";
    Layout = "~/Views/Shared/v1/_Layout.cshtml";
}
@using (Html.BeginForm())
{ 
    <div class="tool_bar">
        <input class="save" type="button" value="保存" /><input class="save" type="button"
            value="复制" /><input class="save" type="button" value="重置" />
    </div>
    <div class="customer_div">
        <label>
            存货地点:</label>
        @Html.TextBoxFor(m => m.Item.Address, new { id = "warehouse_address"})
        <input type="text" />
    </div>
    <div class="customer_div">
        <label>
            所属部门:</label>
        @Html.DropDownListFor(m => m.Item.Department.Id, Model.Departments, new { id = "warehouse_department" })
    </div>
    <div class="customer_div">
        <label>
            仓管员:</label>
        @Html.TextBoxFor(m => m.Item.Employee.Id, new { id = "warehouse_employee"})
        <input type="button" value="选取" /><input type="text" />
    </div>
}
<fieldset>
    <legend class="left_right_bord_0">账户列表</legend>
    <table id="warehouse_dg" toolbar="#tb">
        <thead>
            <tr>
                <th field="ck" checkbox="true"></th>
                <th field="Address" width="80">存货地点
                </th>
                <th field="StrDepartment" width="80">所属部门
                </th>
                <th field="Employee" width="80">仓管员
                </th>
                <th field="Status" width="80">状态
                </th>
            </tr>
        </thead>
    </table>
    <div id="tb">
        <a href="#" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="javascript:alert('批量删除')">批量删除</a> <a href="#" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="javascript:alert('引出')">引出</a>
    </div>
</fieldset>
@section scripts{
    <script type="text/javascript">
        $(function () {
            $("form[action^='/warehouse/add']").submit(function () {
                $.ajax({
                    url: this.action,
                    type: this.method,
                    data: $(this).serialize(),
                    success: function (data) {
                        if (data.IsSuccess) {
                            $('#warehouse_dg').datagrid('reload');
                        }
                    },
                    error: function () {
                        alert('系统繁忙，请稍候再试');
                    }
                })

                return false;
            });

            $('#warehouse_dg').datagrid({
                class: 'easyui-datagrid',
                title: "银行账户",
                idField: 'ID',
                url: "/account/list",
                onClickRow: function (rowIndex, rowData) {
                    $("#warehouse_address").val(rowData.Address);
                    $("select#warehouse_department").attr('value', rowData.Department);
                    $("#warehouse_employee").val(rowData.Employee);
                }
            });
        });
    </script>
}
